-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MUTAGEN_PROJECT_FILE env variable #203
base: master
Are you sure you want to change the base?
Conversation
90603bc
to
bcf65aa
Compare
By default `mutagen project` looks for a config file named 'mutagen.yml' to load project configuration. This change gives us the ability to customize that with an environment variable. Signed-off-by: Julich Mera <julich.mera@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #203 +/- ##
==========================================
- Coverage 49.82% 49.74% -0.09%
==========================================
Files 234 235 +1
Lines 16314 16320 +6
==========================================
- Hits 8129 8118 -11
- Misses 7156 7169 +13
- Partials 1029 1033 +4
Continue to review full report at Codecov.
|
Hi @havoc-io, First and foremost, thank you for the fantastic work you do maintaining mutagen! Your hard work does not go unnoticed. Before I continue with this, do you think it is a feature worth pursing? I opened this PR because I found myself wanting to do this in my project. |
Another note/disclaimer: I am new to golang. This is the first piece of go code I've ever written so please bear with me as I learn it. |
Hey @jmera, thanks for the pull request! I need a little more time to think about this idea, but I wanted to respond at least a little bit with my initial thoughts. At the moment, I'm working on automated Docker Compose integration for Mutagen. I mention this because:
On the other hand, I think other tools are more likely to wrap Mutagen projects than to try to emulate their behavior, so it may not matter. I wouldn't mind a few more days to think about it. Can you tell me a little about your use case? If the logic is kept simple (i.e. a single file, no YAML merging, no |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added two quick review comments. I still wouldn't mind a few more days to mull this over before too much more work gets put into it. In any case, the effort and input is much appreciated!
func ConfigurationFileName() string { | ||
fileName := os.Getenv("MUTAGEN_PROJECT_FILE") | ||
if fileName == "" { | ||
return DefaultConfigurationFileName | ||
} | ||
return fileName | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code looks like it needs to be go fmt
'd since it's using spaces for indentation. You can format all of your changes with
go fmt ./cmd/mutagen/project/...
go fmt ./pkg/project/...
(assuming you're in the root of the source directory).
This is one of those weird Go things, but basically Go's canonical style is "whatever the gofmt
tool decides." For indentation, Go prefers tabs (though it does use spaces for alignment).
@@ -39,7 +39,7 @@ func startMain(command *cobra.Command, arguments []string) error { | |||
// relative paths (including relative synchronization paths and relative | |||
// Unix Domain Socket paths) to be resolved relative to the project | |||
// configuration file. | |||
configurationFileName := project.DefaultConfigurationFileName | |||
configurationFileName := project.ConfigurationFileName() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the MUTAGEN_PROJECT_FILE
environment variable allows a path to be specified (as opposed to just a filename), then I think the same os.Chdir
logic used for a project file specified on the command line will be needed to support relative synchronization paths. This applies at least in the start
command, but I think in the other commands as well.
By default
mutagen project
looks for a config file named 'mutagen.yml'to load project configuration. This change gives us the ability to
customize that with an environment variable.